package com.ss.android.article.browser.main;

import android.annotation.TargetApi;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;

import com.bytedance.common.utility.Logger;

public class MotionDirectionFrameLayout extends FrameLayout {
    MotionDirectionScrollHelper ayVar;

    public MotionDirectionFrameLayout(@NonNull Context context) {
        super(context);
    }

    public MotionDirectionFrameLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public MotionDirectionFrameLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int defaultStyle) {
        super(context, attributeSet, defaultStyle);
    }

    @TargetApi(value = 21)
    public MotionDirectionFrameLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int defaultStyle, int arg4) {
        super(context, attributeSet, defaultStyle, arg4);
    }

    public final boolean a() {
        return this.ayVar != null && this.ayVar.a(-300f);
    }

    boolean dispatchTouchEvent(MotionDirectionFrameLayout targetView, MotionEvent motionEvent) {
        return super.dispatchTouchEvent(motionEvent);
    }

    public void computeScroll() {
        super.computeScroll();
        if (this.ayVar != null) {
            boolean computeResult = this.ayVar.mOverScroller.computeScrollOffset();
            if (computeResult) {
                boolean notFinished = !this.ayVar.mOverScroller.isFinished();
                if (this.ayVar.d != null) {
                    int currY = this.ayVar.mOverScroller.getCurrY();
                    this.ayVar.d.b(currY);
                }
                if (notFinished) {
                    ViewCompat.postInvalidateOnAnimation(this.ayVar.mTargetView);
                }
            }
        }
    }

    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        if (this.getVisibility() != View.VISIBLE) {
            return false;
        } else {
            if (this.ayVar != null && this.ayVar.dispatchTouchEvent(motionEvent)) {
                return true;
            }
            super.dispatchTouchEvent(motionEvent);
            return true;
        }
    }

    public void setReTakeOverTouchEventEdgeType(int arg2) {
        if (this.ayVar != null) {
            this.ayVar.e = arg2;
        }
    }
}

